<script type="text/javascript">
    $(function() {
        $('#dataini').mask('99/99/9999');
        $('#datafim').mask('99/99/9999');
    });
</script>
<?php echo $this->view->menssagem; ?>
<div class="panel panel-default">
    <div class="panel-heading" style="text-align: center;font-weight: bold;">RELATÓRIO DE CONTAS A PAGAR POR PERÍODO</div>
    <div class="panel-body">
        <form action="/caixa/relatorio_periodo" method="post" class="navbar-form navbar-left">
            <div class="form-group">
                <div class="form-group">
                    <input class="form-control" type="text" name="dataini" size="15" id="dataini" placeholder="Data inicial"/>
                </div>
            </div>
            <div class="form-group">
                <div class="form-group">
                    <input class="form-control" type="text" size="15" name="datafim" id="datafim" placeholder="Data final"/>
                </div>
                <button class="btn btn-primary" type="submit" ><span class="glyphicon glyphicon-search"></span> Consultar</button>
            </div>
        </form>
    </div>
</div>
<table class="table table-striped table-hover">
    <thead>
        <tr>
            <th>Documento</th>
            <th>Beneficiario</th>
            <th>Descrição</th>
            <th>Vencimento</th>
            <th style="text-align: right;">Valor</th>
        </tr>
    </thead>
    <tbody>
        <?php
        $total = 0;
        if (isset($this->view->lista)) {
            foreach ($this->view->lista as $c) {
                $total = $total + $c['valor'];
                echo '<tr>';
                echo " <td> ";
                echo $c['numero_documento'];
                echo '</td>';
                echo '<td>';
                echo $c['beneficiario_nome'];
                echo '</td>';
                echo '<td>';
                echo $c['descricao'];
                echo '</td>';
                echo '<td>';
                echo \SON\UTIL\Converter::dataParaString($c['vencimento']);
                echo '</td>';
                echo " <td align='right'> ";
                echo "R$ " . \SON\UTIL\Converter::doubleParaString($c['valor']);
                echo '</td>';
                echo '</tr>';
            }
        }
        ?>
        <tr>
            <th>TOTAL</th>
            <th></th>
            <th></th>
            <th></th>
            <th style="text-align: right;"><?php echo 'R$ ' . SON\UTIL\Converter::doubleParaString($total); ?></th>
        </tr>
    </tbody>
</table>
